home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / c / getsockopt.man < prev    next >
Encoding:
Text File  |  1989-05-15  |  7.9 KB  |  199 lines

  1.  
  2.  
  3.  
  4. GETSOCKOPT            C Library Procedures             GETSOCKOPT
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      getsockopt, setsockopt - get and set options on sockets
  10.  
  11. SSYYNNOOPPSSIISS
  12.      ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
  13.      ##iinncclluuddee <<ssyyss//ssoocckkeett..hh>>
  14.  
  15.      ggeettssoocckkoopptt((ss,, lleevveell,, ooppttnnaammee,, ooppttvvaall,, ooppttlleenn))
  16.      iinntt ss,, lleevveell,, ooppttnnaammee;;
  17.      cchhaarr **ooppttvvaall;;
  18.      iinntt **ooppttlleenn;;
  19.  
  20.      sseettssoocckkoopptt((ss,, lleevveell,, ooppttnnaammee,, ooppttvvaall,, ooppttlleenn))
  21.      iinntt ss,, lleevveell,, ooppttnnaammee;;
  22.      cchhaarr **ooppttvvaall;;
  23.      iinntt ooppttlleenn;;
  24.  
  25. DDEESSCCRRIIPPTTIIOONN
  26.      _G_e_t_s_o_c_k_o_p_t and _s_e_t_s_o_c_k_o_p_t manipulate _o_p_t_i_o_n_s associated with
  27.      a socket.  Options may exist at multiple protocol levels;
  28.      they are always present at the uppermost ``socket'' level.
  29.  
  30.      When manipulating socket options the level at which the
  31.      option resides and the name of the option must be specified.
  32.      To manipulate options at the ``socket'' level, _l_e_v_e_l is
  33.      specified as SOL_SOCKET.  To manipulate options at any other
  34.      level the protocol number of the appropriate protocol con-
  35.      trolling the option is supplied.  For example, to indicate
  36.      that an option is to be interpreted by the TCP protocol,
  37.      _l_e_v_e_l should be set to the protocol number of TCP; see
  38.      _g_e_t_p_r_o_t_o_e_n_t(3N).
  39.  
  40.      The parameters _o_p_t_v_a_l and _o_p_t_l_e_n are used to access option
  41.      values for _s_e_t_s_o_c_k_o_p_t.  For _g_e_t_s_o_c_k_o_p_t they identify a
  42.      buffer in which the value for the requested option(s) are to
  43.      be returned.  For _g_e_t_s_o_c_k_o_p_t, _o_p_t_l_e_n is a value-result
  44.      parameter, initially containing the size of the buffer
  45.      pointed to by _o_p_t_v_a_l, and modified on return to indicate the
  46.      actual size of the value returned.  If no option value is to
  47.      be supplied or returned, _o_p_t_v_a_l may be supplied as 0.
  48.  
  49.      _O_p_t_n_a_m_e and any specified options are passed uninterpreted
  50.      to the appropriate protocol module for interpretation.  The
  51.      include file <_s_y_s/_s_o_c_k_e_t._h> contains definitions for
  52.      ``socket'' level options, described below.  Options at other
  53.      protocol levels vary in format and name; consult the
  54.      appropriate entries in section (4P).
  55.  
  56.      Most socket-level options take an _i_n_t parameter for _o_p_t_v_a_l.
  57.      For _s_e_t_s_o_c_k_o_p_t, the parameter should non-zero to enable a
  58.      boolean option, or zero if the option is to be disabled.
  59.      SO_LINGER uses a _s_t_r_u_c_t _l_i_n_g_e_r parameter, defined in
  60.  
  61.  
  62.  
  63. Sprite v1.0               May 23, 1986                          1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. GETSOCKOPT            C Library Procedures             GETSOCKOPT
  71.  
  72.  
  73.  
  74.      <_s_y_s/_s_o_c_k_e_t._h>, which specifies the desired state of the
  75.      option and the linger interval (see below).
  76.  
  77.      The following options are recognized at the socket level.
  78.      Except as noted, each may be examined with _g_e_t_s_o_c_k_o_p_t and
  79.      set with _s_e_t_s_o_c_k_o_p_t.
  80.  
  81.           SO_DEBUG        toggle recording of debugging information
  82.           SO_REUSEADDR    toggle local address reuse
  83.           SO_KEEPALIVE    toggle keep connections alive
  84.           SO_DONTROUTE    toggle routing bypass for outgoing messages
  85.           SO_LINGER       linger on close if data present
  86.           SO_BROADCAST    toggle permission to transmit broadcast messages
  87.           SO_OOBINLINE    toggle reception of out-of-band data in band
  88.           SO_SNDBUF       set buffer size for output
  89.           SO_RCVBUF       set buffer size for input
  90.           SO_TYPE         get the type of the socket (get only)
  91.           SO_ERROR        get and clear error on the socket (get only)
  92.  
  93.      SO_DEBUG enables debugging in the underlying protocol
  94.      modules.  SO_REUSEADDR indicates that the rules used in
  95.      validating addresses supplied in a _b_i_n_d(2) call should allow
  96.      reuse of local addresses.  SO_KEEPALIVE enables the periodic
  97.      transmission of messages on a connected socket.  Should the
  98.      connected party fail to respond to these messages, the con-
  99.      nection is considered broken and processes using the socket
  100.      are notified via a SIGPIPE signal.  SO_DONTROUTE indicates
  101.      that outgoing messages should bypass the standard routing
  102.      facilities.  Instead, messages are directed to the appropri-
  103.      ate network interface according to the network portion of
  104.      the destination address.
  105.  
  106.      SO_LINGER controls the action taken when unsent messags are
  107.      queued on socket and a _c_l_o_s_e(2) is performed.  If the socket
  108.      promises reliable delivery of data and SO_LINGER is set, the
  109.      system will block the process on the _c_l_o_s_e attempt until it
  110.      is able to transmit the data or until it decides it is
  111.      unable to deliver the information (a timeout period, termed
  112.      the linger interval, is specified in the _s_e_t_s_o_c_k_o_p_t call
  113.      when SO_LINGER is requested). If SO_LINGER is disabled and a
  114.      _c_l_o_s_e is issued, the system will process the close in a
  115.      manner that allows the process to continue as quickly as
  116.      possible.
  117.  
  118.      The option SO_BROADCAST requests permission to send broad-
  119.      cast datagrams on the socket.  Broadcast was a privileged
  120.      operation in earlier versions of the system.  With protocols
  121.      that support out-of-band data, the SO_OOBINLINE option
  122.      requests that out-of-band data be placed in the normal data
  123.      input queue as received; it will then be accessible with
  124.      _r_e_c_v or _r_e_a_d calls without the MSG_OOB flag.  SO_SNDBUF and
  125.      SO_RCVBUF are options to adjust the normal buffer sizes
  126.  
  127.  
  128.  
  129. Sprite v1.0               May 23, 1986                          2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. GETSOCKOPT            C Library Procedures             GETSOCKOPT
  137.  
  138.  
  139.  
  140.      allocated for output and input buffers, respectively.  The
  141.      buffer size may be increased for high-volume connections, or
  142.      may be decreased to limit the possible backlog of incoming
  143.      data.  The system places an absolute limit on these values.
  144.      Finally, SO_TYPE and SO_ERROR are options used only with
  145.      _s_e_t_s_o_c_k_o_p_t.  SO_TYPE returns the type of the socket, such as
  146.      SOCK_STREAM; it is useful for servers that inherit sockets
  147.      on startup.  SO_ERROR returns any pending error on the
  148.      socket and clears the error status.  It may be used to check
  149.      for asynchronous errors on connected datagram sockets or for
  150.      other asynchronous errors.
  151.  
  152. RREETTUURRNN VVAALLUUEE
  153.      A 0 is returned if the call succeeds, -1 if it fails.
  154.  
  155. EERRRROORRSS
  156.      The call succeeds unless:
  157.  
  158.      [EBADF]             The argument _s is not a valid descrip-
  159.                          tor.
  160.  
  161.      [ENOTSOCK]          The argument _s is a file, not a socket.
  162.  
  163.      [ENOPROTOOPT]       The option is unknown at the level indi-
  164.                          cated.
  165.  
  166.      [EFAULT]            The address pointed to by _o_p_t_v_a_l is not
  167.                          in a valid part of the process address
  168.                          space.  For _g_e_t_s_o_c_k_o_p_t, this error may
  169.                          also be returned if _o_p_t_l_e_n is not in a
  170.                          valid part of the process address space.
  171.  
  172. SSEEEE AALLSSOO
  173.      ioctl(2), socket(2), getprotoent(3N)
  174.  
  175. BBUUGGSS
  176.      Several of the socket options should be handled at lower
  177.      levels of the system.
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. Sprite v1.0               May 23, 1986                          3
  196.  
  197.  
  198.  
  199.